﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using NET4.DataNET4Postcode;
using NET4.DataNET4Postcode.Repository;

namespace NET4.Webservice
{
  [WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [ToolboxItem(false)]
  public class PostcodeService : System.Web.Services.WebService
  {
    [WebMethod]
    public Address GetStreetAndCity(String zipCode)
    {
      Address address = new Address();

      Postcode postcode = PostcodeRepository.Instance.SelectByZipCode(zipCode);
      if (postcode != null)
      {
        address = new Address(postcode.Straat, postcode.Plaats);
      }
      return address;
    }
  }

  [Serializable]
  public class Address
  {
    private String street;
    private String city;

    public Address() { }
    public Address(String street, String city)
    {
      this.street = street;
      this.city = city;
    }

    public String Street
    {
      get { return this.street; }
      set { this.street = value; }
    }

    public String City
    {
      get { return this.city; }
      set { this.city = value; }
    }
  }
}
